package com.xingyun.kingdee.erp.service.provider;

import com.alibaba.fastjson.JSONObject;
import com.xingyun.kingdee.erp.common.model.api.ErpApi;
import com.xingyun.kingdee.erp.common.model.param.base.ErpLoginParam;
import com.xingyun.kingdee.erp.common.model.param.opt.*;
import com.xingyun.kingdee.erp.common.model.response.Result;
import com.xingyun.kingdee.erp.service.service.ErpService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>Title: erp服务接口实现提供</p>
 * <p>Description: </p>
 *
 * @author zhangxiong
 * @date 2020年04月03日
 */
@Api("erp接口服务")
@RestController
@RequestMapping("/erp")
public class ErpDockProvider implements ErpApi {

    @Autowired
    private ErpService erpService;

    @Override
    @PostMapping("save")
    public Result<JSONObject> save(@RequestBody @Valid ErpSaveFormParam erpSaveParam) {
        return Result.success(erpService.save(erpSaveParam));
    }

    @Override
    @PostMapping("billQuery")
    public Result<Object> billQuery(@RequestBody @Valid ErpBillQueryParam erpBillQueryParam) {
        return Result.success(erpService.billQuery(erpBillQueryParam));
    }

    @Override
    @PostMapping("audit")
    public Result<JSONObject> audit(@RequestBody @Valid ErpAuditParam erpAuditParam) {
        return Result.success(erpService.audit(erpAuditParam));
    }

    @Override
    @PostMapping("unAudit")
    public Result<JSONObject> unAudit(@RequestBody @Valid ErpUnAuditParam erpUnAuditParam) {
        return Result.success(erpService.unAudit(erpUnAuditParam));
    }

    @Override
    @PostMapping("submit")
    public Result<JSONObject> submit(@RequestBody @Valid ErpSubmitParam erpSubmitParam) {
        return Result.success(erpService.submit(erpSubmitParam));
    }

    @Override
    @PostMapping("view")
    public Result<JSONObject> view(@RequestBody @Valid ErpViewParam erpViewParam) {
        return Result.success(erpService.view(erpViewParam));
    }

    @Override
    @PostMapping("delete")
    public Result<JSONObject> delete(@RequestBody @Valid ErpDeleteParam erpDeleteParam) {
        return Result.success(erpService.delete(erpDeleteParam));
    }

    @Override
    @PostMapping("push")
    public Result<JSONObject> push(@RequestBody @Valid ErpPushDownParam erpPushParam) {
        return Result.success(erpService.push(erpPushParam));
    }

    @Override
    @PostMapping("loginToGetCookie")
    public Result<List<String>> loginToGetCookie(@RequestBody @Valid ErpLoginParam erpLoginParam) {
        return Result.success(erpService.loginToGetCookie(erpLoginParam));
    }
}
